package com.hmall.search.controller;


import com.hmall.common.dto.PageDTO;
import com.hmall.common.pojo.ItemDoc;

import com.hmall.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.hmall.common.pojo.RequestParams;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author xk
 * @since 2023-12-21
 */
@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private SearchService searchService;

    // 分页条件查询
    @PostMapping("/list")
    public PageDTO<ItemDoc> search(@RequestBody RequestParams params) throws IOException {
        return searchService.search(params);
    }

    // 聚合查询
    @PostMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody RequestParams params) throws IOException{
        return searchService.filters(params);
    }

}
